""" 
esp32 adc 模拟电路转数字
adc引脚 gpio34

API:
adc.read() 返回0-4095, 表示0-1v电压

"""

from machine import Pin
from machine import ADC
import time

adc = ADC(Pin(34))
adc.atten(ADC.ATTN_11DB)  # 设置衰减为11db


if __name__ == "__main__":
    while True:
        adc_vol = 3.3 * adc.read() / 4095
        print("adc 采集值：{}".format(adc_vol))
        time.sleep(1)
